
// Script function: Mask all pixels within a circular area around the center of the image
// Requirement to run the script: Open an image

// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html


image imgInitial, imgMask, ProducedImg

if ( !GetFrontImage( imgInitial ) )
 Throw( "Please open an image." )

number imagexsize, imageysize
getsize(imgInitial, imagexsize, imageysize)

number EMx = imagexsize/2
number EMy = imageysize/2
number radius = imagexsize/10

imgMask = imgInitial * 0  
imgMask = ( ( icol - EMx )**2 + ( irow - EMy )**2 < radius**2 ) ? 1 : 0                

ProducedImg := imgMask ? imgInitial : 0

SetName( ProducedImg, "Image masked from '" + GetName( imgInitial ) +"'"   )
ShowImage( ProducedImg ) 
